<script>
import {post} from "./api/myHttps";

export default {
  onLaunch: function () {
    console.log('App Launch')
    uni.removeStorageSync("ownerId");
    uni.removeStorageSync("openid");
    uni.removeStorageSync("phone");
    uni.login({
      provider: 'weixin',
      success: function (res) {
        console.log('res', res);
        post('/city-mobile/eulbOpenId', {
          code: res.code,
          appId: uni.getAccountInfoSync().miniProgram.appId,
        }).then((res) => {
          uni.setStorageSync("openid", res.openid);
          uni.setStorageSync("ownerId", res.ownerId);
          uni.setStorageSync("phone", res.phone);
          uni.setStorageSync("username", res.username);
          uni.setStorageSync("userImg", res.userImg);
          uni.$emit('init', null)

          // todo:模拟测试
          // uni.setStorageSync("ownerId", 1);
        })
      }
    });
  },
  onShow: function () {
    console.log('App Show')
  },
  onHide: function () {
    console.log('App Hide')
  }
}
</script>

<style lang="scss">
@import "@/uni_modules/uview-ui/index.scss";
/*每个页面公共css */
@import "/static/css/pubilc.scss";
@import '/static/css/style.scss';
</style>
